#include "stdafx.h"
#include "qclosewindowfilter.h"
#include "connection.h"
#include <QByteArray>

#ifdef Q_CC_MSVC
#include <windows.h>
#include <qwindowdefs_win.h>
#pragma comment(lib, "user32.lib")
#endif


QCloseWindowFilter::QCloseWindowFilter()
{
}


QCloseWindowFilter::~QCloseWindowFilter()
{
}

bool QCloseWindowFilter::nativeEventFilter(const QByteArray& eventType, void* message, qintptr* result)
{
	Q_UNUSED(result);
	if (eventType == "windows_generic_MSG" ||
		eventType == "windows_dispatcher_MSG"
		)
	{
		MSG* pMsg = reinterpret_cast<MSG*>(message);
		if (pMsg->message == WM_QUERYENDSESSION)
		{
			setStopTime();
			return true;
		}
	}

	return false;
}